define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'shop.settle/index',
        add_url: 'shop.settle/add',
        edit_url: 'shop.settle/edit',
        delete_url: 'shop.settle/delete',
        export_url: 'shop.settle/jsExport',
        modify_url: 'shop.settle/modify',
        handle_url: 'shop.settle/handle',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                toolbar: ['refresh'],
                init: init,
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id'},
                    // {field: 'shop_id', title: 'shop_id'},
                    {field: 'shop_name', title: '店铺名称'},
                    {field: 'shop_address', title: '店铺地址'},
                    {field: 'shop_keeper', title: '联系人'},
                    {field: 'shop_mobile', title: '联系电话'},
                    {
                        field: 'settle_status', title: '状态',
                        selectList: {'0': '待审核', '1': '通过', '-1': '拒批'},
                        templet: function (d) {
                            if (d.settle_status == '-1') {
                                return '<span style="color:red;">拒批</span>';
                            } else if (d.settle_status == '0') {
                                return '<span style="color:orange;">待审核</span>';
                            } else if (d.settle_status == '1') {
                                return '<span style="color:green;">通过</span>';
                            } else return '位置状态'
                        }
                    },
                    {field: 'create_time', title: '申请时间', search: 'range'},
                    {
                        width: 150, title: '操作', templet: ea.table.tool,
                        operate:
                            [
                                [
                                    {
                                        method: 'request',
                                        field: 'id',
                                        icon: 'fa fa-check',
                                        title: '确定通过？',
                                        text: '通过',
                                        url: init.handle_url + '?status=1',
                                        auth: 'handle',
                                        class: 'layui-btn layui-btn-success layui-btn-xs',
                                        br: true,
                                    },
                                    {
                                        method: 'request',
                                        field: 'id',
                                        icon: 'fa fa-close',
                                        text: '拒批',
                                        title: '确定拒批？',
                                        url: init.handle_url + '?status=-1',
                                        auth: 'handle',
                                        class: 'layui-btn layui-btn-danger layui-btn-xs',
                                        // data:{iotid:'123test123'}
                                    },
                                ],
                            ]

                    },
                ]],
            });
            //悬停选中事件

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});